<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>XXX图书管理系统</title>
    <style type="text/css">
        .imgheight{
            height: 50px;
        }
    </style>
</head>
<body>

<a href="index.php">返回首页</a><br>
<button type="button" onclick="history.go(-1);">返回上一页</button>
<?php
try {
    $dsn = 'mysql:dbname=Library;host=127.0.0.1';
    $user = 'root';
    $password = '123456';
    $db = new PDO($dsn, $user, $password);
    $statement=$db->prepare('select * from Book WHERE ID=:id');
    $statement->execute([':id'=>$_GET['id']]);
    $result=$statement->fetch();
   // var_dump($result);

} catch (PDOException $e) {
    var_dump($e->getMessage());
    die('程序出错');
}


?>

<?php
if(empty($result)){
    echo"404书籍不存在";
    $url='/index.php';
    echo "<a href='".$url."'>".'返回首页'."</a>";
}else{
    echo "<h1>".$result['Name']."</h1>";
    echo "<p>作者：".$result['Author']."</p>";
    echo "<p>介绍：".$result['Intro']."</p>";
    echo "<div class='bookimg'><img class='imgheight' src=".$result['BookImg'].'></div>';

}
?>





</body>
</html>
